% 20241114_07h23m28s
clear
clc
instrreset
% addpath 临时添加驱动文件所在的路径
% addpath('E:\001_Users\Backup\00MatlabVNAlib\Matlab');
% addpath('F:\SoftData\Matlab\00_my_vna_lib');
% VNA = jwlong_3672C_class.Conect('keysight','TCPIP0::192.168.100.2::5025::SOCKET');
% VNA = jwlong_E8363B_class.Conect('keysight','TCPIP0::192.168.100.2::5025::SOCKET');
% VNA = jwlong_N5227B_class.Conect('keysight','TCPIP0::192.168.100.2::5025::SOCKET');
% VNA=jwlong_ZNLE18_class.Conect('keysight','TCPIP0::192.168.100.2::5025::SOCKET');
VNA=jwlong_ZNB40_class.Conect('keysight','TCPIP0::192.168.100.2::5025::SOCKET');
VNA.SetPreSet();
VNA.SetTrace('S11')
pause(1)
VNA.SetFreq('START',7*1e9);
VNA.SetFreq('STOP',9*1e9);
pause(1)
VNA.SetAutoScale(); 
% filename='20230427/test';
% f=[2.66,3.41,4.469]*1e9;
f=[8.1]*1e9;
% f=4.4695e9;
% f=4.46e9;
VNA.SetTrace('S21')

for k=1:max(size(f))
% VNA.SetMarker('MAX',1);
[test.fbw(k),test.f0(k),test.Q0(k),test.loss(k)]=VNA.FindQ(f(k),200e6);
end
% save(filename,'test') 


trace1 = VNA.ReadTrace();
plot(trace1.freq,trace1.mag)

traceF = VNA.ReadTraceF();
hold on
plot(traceF.freq,traceF.mag)